//
//  MessagePannel.m
//  Guazi
//
//  Created by 李 电森 on 11-8-17.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "MessagePannel.h"


@implementation MessagePannel

- (id)initWithFrame:(CGRect)aframe
{
    self = [super initWithFrame:aframe];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor colorWithRed:0.7f green:0.7f blue:0.8f alpha:0.9f];

        indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(aframe.size.width - 40, (aframe.size.height - 30)/2,
                                                                              30, 30)];
        [self addSubview:indicator];
        
        messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, aframe.size.width, aframe.size.height)];
        messageLabel.backgroundColor = [UIColor clearColor];
        messageLabel.font = [UIFont systemFontOfSize:14];
        messageLabel.textColor = [UIColor whiteColor];
        messageLabel.textAlignment = UITextAlignmentCenter;
        [self addSubview:messageLabel];
        
    }
    return self;
}


- (void) startIndicator
{
    [indicator startAnimating];
}


- (void) stopIndicator
{
    [indicator stopAnimating];
}


- (void) setMessage:(NSString*)message
{
    messageLabel.text = message;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/


- (void)dealloc
{
    [indicator release];
    [messageLabel release];
    [super dealloc];
}

@end
